﻿using DapperExtensions;
using SAICAPPWEB.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SAICAPPWEB.BLL
{
    public class ProjectTimeBll:BaseBll<ProjectTime>
    {
        public bool Exit(string  phonesn)
        {
            IList<IPredicate> predList = new List<IPredicate>();
            predList.Add(Predicates.Field<ProjectTime>(p => p.PhoneSn, Operator.Eq, phonesn));
            predList.Add(Predicates.Field<ProjectTime>(p => p.Date, Operator.Eq, DateTime.Now.ToString("yyyyMMdd")));
            IPredicateGroup ipg = Predicates.Group(GroupOperator.And, predList.ToArray());
            var result = Db.GetList<ProjectTime>(ipg).FirstOrDefault();
            if(result==null)
            {
                return false;
            }
            Db.Connection.Close();
            return true;
        }
    }
}